package com.whatever;

import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class SpinnerProjectActivity extends Activity implements OnClickListener {
    
	public int[] spinnerMap = {
			R.id.spinner0,
			R.id.spinner1,
			R.id.spinner2
	};
	
	public int[] buttonMap = {
			R.id.button0
	};
	
	public Spinner[] spinner;
	public Button[] button;
	public ArrayAdapter adapter0;
	public ArrayAdapter adapter1;
	public ArrayAdapter adapter2;
	public Calendar calendar;
	public String output;
	public int btnId;
	public int currentDay;
	public int currentMonth;
	public int currentYear;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        for(int i = 0; i < buttonMap.length; i++) {
        	button[i] = (Button)findViewById(buttonMap[i]);	
        }
        
        for(int i = 0; i < spinnerMap.length; i++) {
        	spinner[i] = (Spinner)findViewById(spinnerMap[i]);
        }
        
        Calendar.getInstance();
        currentDay = calendar.get(Calendar.DAY_OF_YEAR);
        currentMonth = calendar.get(Calendar.MONTH);
        currentYear = calendar.get(Calendar.YEAR);
        
        adapter0 = ArrayAdapter.createFromResource(this, R.array.Years, android.R.layout.simple_spinner_item);
        adapter1 = ArrayAdapter.createFromResource(this, R.array.Months, android.R.layout.simple_spinner_item);
        adapter2 = ArrayAdapter.createFromResource(this, R.array.Days, android.R.layout.simple_spinner_item);
        
        spinner[0].setAdapter(adapter0);
        spinner[1].setAdapter(adapter1);
        spinner[2].setAdapter(adapter2);
    
    
    
    }

	public void onClick(View v) {
		
	}
	
	public int getAge(int birthDay, int birthMonth, int birthYear, int format) {
		int result = 0;
		if(format == 0) //Format in years
			result = currentYear - birthYear;
		if(format == 1) { //Format in months
			result = ((currentYear - birthYear) * 12) + currentMonth - birthMonth;
		}
		if(format == 2) {
			result = currentDay - birthDay;
		}
		return result;
	}
}